/**
 * 
 */
package org.tcp.client.pool;

import java.io.IOException;
import java.net.UnknownHostException;

/**
 * tcp connection pool interface
 * 
 * @author kucheng.liao@autonavi.com
 * @Date Sep 19, 2014
 */
public interface Pool {
	/**
	 * get a connection from pool,it while blocking if the pool is empty;
	 * 
	 * @return
	 */
	public ITcpConnection poll();

	/**
	 * back the connection to pool;
	 * 
	 * @param t
	 */
	public void push(ITcpConnection t);

	/**
	 * destory the pool;
	 */
	public void destory();

	/**
	 * init the pool of connection
	 * 
	 * @return
	 */
	public boolean init(PoolConfig config) throws UnknownHostException, IOException;

	/**
	 * the total number of connections,
	 * 
	 * @return
	 */
	public int getTotalSize();

	/**
	 * the max nubmer of pool
	 * 
	 * @return
	 */
	public int getMaxSize();

	/**
	 * the min nubmer of pool
	 * 
	 * @return
	 */
	public int getMinSize();

	/**
	 * the size of pool, it must less than maxSize and more than minsize
	 * 
	 * @return
	 */
	public int getSize();

	/**
	 * add the size
	 * 
	 * @param i
	 */
	public void addSize(int i);

	/**
	 *
	 */
	public void decrementTotal();
}
